package com.autumn.juc.lock;

public class LockEliminationTest {
    /**
     * 锁消除
     * ‐XX:+EliminateLocks  开启锁消除(jdk8默认开启）
     * -XX:-EliminateLocks  关闭锁消除
     * @param str1
     * @param str2
     */
    public void append(String str1, String str2) {
        StringBuffer buffer = new StringBuffer();
        buffer.append(str1).append(str2);
    }

    public static void main(String[] args) {
        LockEliminationTest test = new LockEliminationTest();
        long start = System.currentTimeMillis();
        for (int i = 0; i < 100000000; i++) {
            test.append("aaa", "bbb");
        }
        long end = System.currentTimeMillis();
        System.out.println(">>>>>>>>>> 执行时间：" + (end - start) + " ms");
    }
}
